<?
//connect to database
$dbhost = 'localhost';
$dbuser = 'username';
$dbpass = 'password';
$dbname = 'bdname';

$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname);

//NOTE: MAKE SURE YOU DO YOUR OWN APPROPRIATE SERVERSIDE ERROR CHECKING HERE!!!
if(!empty($_POST) && isset($_POST))
{
	//make variables safe to insert
  $name = mysql_real_escape_string($_POST['name']);
  $surname = mysql_real_escape_string($_POST['surname']);

	//query to insert data into table
	$sql = "
		INSERT INTO table_refresh
		SET
		firstname = '$name',
		surname = '$surname'";
	$result = mysql_query($sql);
	if(!$result)
	{
		echo "Failed to insert record";
	}
	else
	{
		echo "Record inserted successfully";
	}
}
?>

<table width="300" border="1">
	<tr>
		<td><b>#</b></td>
		<td><b>Name</b></td>
		<td><b>Email</b></td>
	</tr>
	<?
	//show data from tables
	$sql = "
		SELECT *
		FROM table_refresh
		ORDER BY uniqueid ASC
		LIMIT 20";
	$result = mysql_query($sql);
	while($row = mysql_fetch_array($result))
	{
	//print data
	?>
	<tr>
		<td><? echo $row['uniqueid']; ?></td>
		<td><? echo $row['firstname']; ?></td>
		<td><? echo $row['surname']; ?></td>
	</tr>
	<?
	}
	?>
</table>